<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="WHIT">
<span class='line'>  2</span> </span><span class="COMM">/**
<span class='line'>  3</span>  * @fileoverview Date format library.
<span class='line'>  4</span>  * @link http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
<span class='line'>  5</span>  * @link https://developers.google.com/closure/compiler/docs/js-for-compiler
<span class='line'>  6</span>  */</span><span class="WHIT">
<span class='line'>  7</span> 
<span class='line'>  8</span> 
<span class='line'>  9</span> 
<span class='line'> 10</span> </span><span class="COMM">/**
<span class='line'> 11</span>  * Constructor of DateFormatter.
<span class='line'> 12</span>  * @requires locale.Calendar
<span class='line'> 13</span>  * @constructor
<span class='line'> 14</span>  */</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="NAME">formatters.DateFormatter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 16</span> 
<span class='line'> 17</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 18</span>    * Formats given &lt;code>date&lt;/code> according to given &lt;code>format&lt;/code>.
<span class='line'> 19</span>    * @param {Date} date The Date to be formatted.
<span class='line'> 20</span>    * @param {string} format The date format.
<span class='line'> 21</span>    * @return {string} The formatted date as string.
<span class='line'> 22</span>    * @example
<span class='line'> 23</span>    * &lt;b>var&lt;/b> formatter = &lt;b>new&lt;/b> formatters.DateFormatter();
<span class='line'> 24</span>    * formatter.format(&lt;b>new&lt;/b> Date(), 'YYYY-MM-dd');
<span class='line'> 25</span>    * formatter.format(&lt;b>new&lt;/b> Date(), 'YYYY-MM-dd hh:mm');
<span class='line'> 26</span>    * formatter.format(&lt;b>new&lt;/b> Date(), 'dd MMM, YYYY');
<span class='line'> 27</span>    */</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">  </span><span class="NAME">this.format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">date</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {string} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">calendar_.getMonthName</span><span class="PUNC">(</span><span class="NAME">date</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {!Array.&lt;string, number>} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">      </span><span class="STRN">'YYYY'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">date.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">      </span><span class="STRN">'YY'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">date.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">      </span><span class="STRN">'MMMM'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">      </span><span class="STRN">'MMM'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">      </span><span class="STRN">'MM'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">date.getMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">      </span><span class="STRN">'dd'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">date.getDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">      </span><span class="STRN">'hh'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">date.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">      </span><span class="STRN">'mm'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">date.getMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">      </span><span class="STRN">'ss'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">date.getSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">    </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {number} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tokens.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="COMM">/** @type {number} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">;</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">      </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format.replace</span><span class="PUNC">(</span><span class="NAME">tokens</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tokens</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> 
<span class='line'> 48</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 49</span>    * Parses given date &lt;code>str&lt;/code>  according to given &lt;code>format&lt;/code>.
<span class='line'> 50</span>    * @param {string} str The date string to be parsed.
<span class='line'> 51</span>    * @param {string} format The date format.
<span class='line'> 52</span>    * @return {Date} The parsed date.
<span class='line'> 53</span>    * @example
<span class='line'> 54</span>    * &lt;b>var&lt;/b> formatter = &lt;b>new&lt;/b> formatters.DateFormatter();
<span class='line'> 55</span>    * formatter.parse('2013-01-31', 'YYYY-MM-dd');
<span class='line'> 56</span>    * formatter.parse('2013-01-31 20:30', 'YYYY-MM-dd hh:mm');
<span class='line'> 57</span>    * formatter.parse('03 Jan, 2013', 'dd MMM, YYYY');
<span class='line'> 58</span>    */</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="NAME">this.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {!RegExp} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">re</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/[\/\s,\.\:\-]/</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {!Array.&lt;string>} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dateParts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.split</span><span class="PUNC">(</span><span class="NAME">re</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {!Array.&lt;string>} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">formatParts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format.split</span><span class="PUNC">(</span><span class="NAME">re</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {!Object.&lt;string, string>} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">map</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {number} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">Math.min</span><span class="PUNC">(</span><span class="NAME">dateParts.length</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">formatParts.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">      </span><span class="COMM">/** @type {string} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">formatParts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dateParts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 69</span> 
<span class='line'> 70</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {number} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'YYYY'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">'20'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'YY'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {number} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'MM'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'MMMM'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'MMM'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">      </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">calendar_.getMonthByName</span><span class="PUNC">(</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'MMMM'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'MMM'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'dd'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">        </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">year</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'dd'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'hh'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">               </span><span class="PUNC">+</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'mm'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="NAME">map</span><span class="PUNC">[</span><span class="STRN">'ss'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">dom.NULL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> 
<span class='line'> 80</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 81</span>    * @type {!locale.Calendar}
<span class='line'> 82</span>    * @private
<span class='line'> 83</span>    */</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">calendar_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">locale.Calendar</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> 
<span class='line'> 87</span> 
<span class='line'> 88</span> </span><span class="COMM">/**
<span class='line'> 89</span>  * Formats given &lt;code>date&lt;/code> according to given &lt;code>format&lt;/code>.
<span class='line'> 90</span>  * @param {Date} date The Date to be formatted.
<span class='line'> 91</span>  * @param {string} format The date format.
<span class='line'> 92</span>  * @return {string} The formatted date as string.
<span class='line'> 93</span>  * @static
<span class='line'> 94</span>  * @example
<span class='line'> 95</span>  * formatters.DateFormatter.format(&lt;b>new&lt;/b> Date(), 'YYYY-MM-dd');
<span class='line'> 96</span>  * formatters.DateFormatter.format(&lt;b>new&lt;/b> Date(), 'YYYY-MM-dd hh:mm');
<span class='line'> 97</span>  * formatters.DateFormatter.format(&lt;b>new&lt;/b> Date(), 'dd MMM, YYYY');
<span class='line'> 98</span>  */</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="NAME">formatters.DateFormatter.format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">date</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">formatters.DateFormatter.formatter_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">    </span><span class="NAME">formatters.DateFormatter.formatter_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter.formatter_.format</span><span class="PUNC">(</span><span class="NAME">date</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> 
<span class='line'>106</span> 
<span class='line'>107</span> </span><span class="COMM">/**
<span class='line'>108</span>  * Parses given date &lt;code>str&lt;/code>  according to given &lt;code>format&lt;/code>.
<span class='line'>109</span>  * @param {string} str The date string to be parsed.
<span class='line'>110</span>  * @param {string} format The date format.
<span class='line'>111</span>  * @return {Date} The parsed date.
<span class='line'>112</span>  * @static
<span class='line'>113</span>  * @example
<span class='line'>114</span>  * &lt;b>var&lt;/b> formatter = &lt;b>new&lt;/b> formatters.DateFormatter();
<span class='line'>115</span>  * formatter.parse('2013-01-31', 'YYYY-MM-dd');
<span class='line'>116</span>  * formatter.parse('2013-01-31 20:30', 'YYYY-MM-dd hh:mm');
<span class='line'>117</span>  * formatter.parse('03 Jan, 2013', 'dd MMM, YYYY');
<span class='line'>118</span>  */</span><span class="WHIT">
<span class='line'>119</span> </span><span class="NAME">formatters.DateFormatter.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">formatters.DateFormatter.formatter_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">    </span><span class="NAME">formatters.DateFormatter.formatter_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter.formatter_.parse</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span></pre></body></html>